#include "Place.h"

pn::Place::Place()
{
	setId("unknown-id");
	setTokens(0);
}

pn::Place::Place(const std::string& rId, unsigned int vTokens)
{
	setId(rId);
	setTokens(vTokens);
}

pn::Place::~Place()
{
	
}

std::string pn::Place::getId()
{
	return mId;
}

void pn::Place::setId(const std::string& rId)
{
	if (!rId.empty()) mId.assign(rId);
	else mId = "unknown-id";
}

unsigned int pn::Place::getTokens()
{
	return mTokens;
}

void pn::Place::setTokens(unsigned int vTokens)
{
	mTokens = vTokens;
}

unsigned int pn::Place::addTokens(unsigned int vTokens)
{
	mTokens += vTokens;
	return mTokens;
}

unsigned int pn::Place::remTokens(unsigned int vTokens)
{
	if (vTokens < mTokens) mTokens -= vTokens;
	else mTokens = 0;
	return mTokens;
}

void pn::Place::addTransitionFrom(const pn::TransitionToPlace* pTransitionFrom)
{
	mTransitionsFrom.push_back(pTransitionFrom);
}

void pn::Place::addTransitionTo(const pn::PlaceToTransition* pTransitionTo)
{
	mTransitionsTo.push_back(pTransitionTo);
}
